//配置axios请求 基地址
axios.defaults.baseURL="https://mock.apipark.cn/m1/4727400-4379893-default"
//抽取轻提示函数
//showToast("xxxxxx")
function showToast(msg){
    const toastDom = document.querySelector(".my-toast")
    //实例化toast组件
    const toast =new bootstrap.Toast(toastDom)
    //修改内容
    document.querySelector(".toast-body").innerHTML = msg
    //显示
    toast.show() 
}
//抽取校验函数(判断是否登录)
function checkLogin(){
    //判断token
    const token =localStorage.getItem("token")
    if(token==null){
        showToast("非法访问，请先登录！")
        setTimeout(()=>{
            location.href = "./login.html"
        },1500)
    }
}
//抽取渲染函数(渲染缓存中的用户名)
function renderUsername(){
    const username =localStorage.getItem("username")
    document.querySelector(".username").innerHTML = username
}
//抽取退出誉录函数

function registerLoginOut(){
    //绑定点击事件
    document.querySelector("#logout").addEventListener("click",() =>{
        //console.log(12345);
        localStorage.removeItem("username")
        localStorage.removeItem("token")
        location.href="./login.html"
    })
}